import type { Project } from './model';

import type { ID, PageResult } from '#/api/common';

import { requestClient } from '#/api/request';

enum Api {
  projectDelete = '/project/v1/deleteProject',
  projectList = '/project/v1/pageList',
  projectSave = '/project/v1/saveProject',
  projectUpdate = '/project/v1/updateProject',
}

/**
 * 项目分页列表
 * @param data 请求参数
 * @returns 列表
 */
export function projectList(data?: any) {
  return requestClient.post<PageResult<Project>>(Api.projectList, data);
}

/**
 * 新增项目
 * @param data 参数
 */
export function projectAdd(data: Partial<Project>) {
  return requestClient.postWithMsg<void>(Api.projectSave, data);
}

/**
 * 更新项目
 * @param data 参数
 */
export function projectUpdate(data: Partial<Project>) {
  return requestClient.postWithMsg<void>(Api.projectUpdate, data);
}

/**
 * 删除项目
 * @param projectId 项目ID
 */
export function projectRemove(projectId: ID) {
  return requestClient.get<void>(`${Api.projectDelete}?id=${projectId}`);
}
